package com.cachopoid.activity;

import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TextView;

import com.cachopoid.R;
import com.cachopoid.db.DataBaseHelper;
import com.cachopoid.utils.Constantes;

public class MainActivity extends TabActivity implements OnTabChangeListener {
	
	private Context context;
    private DataBaseHelper dataBaseHelper;
    TabHost tabHost = null;
    Resources res = null;
    TextView tb1 = null;
    TextView tb2 = null;
    Intent intent;
   
    
    public void onCreate(Bundle savedInstanceState) {
    	
    	
        super.onCreate(savedInstanceState);
        //Creamos el contenedor de Tabs
        tabHost = getTabHost();
        TabHost.TabSpec spec;
        Intent intent;
        res = getResources();
     
        intent = new Intent(this, MapaActivity.class);
        //Primer Tab
        spec = tabHost.newTabSpec(Constantes.TAB_MAPA).setIndicator("MAPA", res.getDrawable(R.drawable.activity_mapa)).setContent(intent);
        tabHost.addTab(spec);
        tabHost.getTabWidget().getChildAt(0).setBackgroundDrawable(res.getDrawable(R.drawable.pestana_activa));
        tb1 = (TextView) tabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title);
        tb1.setBackgroundColor(R.style.backGroundTextTab);
        tb1.setTextColor(Color.parseColor("#B0E0E6"));
        tb1.setTextSize(20);
        tb1.setTypeface(null, Typeface.BOLD);
        
        intent = new Intent(this, ListaActivity.class);
        //Segundo Tab
        spec = tabHost.newTabSpec(Constantes.TAB_LISTADO).setIndicator("RANKING", res.getDrawable(R.drawable.activity_lista)).setContent(intent);
        tabHost.addTab(spec);
        tabHost.getTabWidget().getChildAt(1).setBackgroundDrawable(res.getDrawable(R.drawable.pestana_inactiva));
        tb2 = (TextView) tabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title);
        
        tb2.setBackgroundColor(R.style.backGroundTextTab);
        tb2.setTextColor(Color.WHITE);
        tb2.setTypeface(null, Typeface.BOLD);
      
        
        tabHost.setOnTabChangedListener(this);
        
    }
    
    @Override
    protected void onDestroy() {
    	super.onDestroy();
    	
    }

	@Override
		public void onTabChanged(String tabId) {
			if(Constantes.TAB_MAPA.equals(tabId)){
				tabHost.getTabWidget().getChildAt(0).setBackgroundDrawable(res.getDrawable(R.drawable.pestana_activa));
				tabHost.getTabWidget().getChildAt(1).setBackgroundDrawable(res.getDrawable(R.drawable.pestana_inactiva));
				tb1.setTextColor(Color.parseColor("#B0E0E6"));
				tb1.setTextSize(20);
				tb2.setTextSize(15);
				tb2.setTextColor(Color.WHITE);
				
				
			}
			if(Constantes.TAB_LISTADO.equals(tabId)){

				tabHost.getTabWidget().getChildAt(0).setBackgroundDrawable(res.getDrawable(R.drawable.pestana_inactiva));
				tabHost.getTabWidget().getChildAt(1).setBackgroundDrawable(res.getDrawable(R.drawable.pestana_activa));
				tb1.setTextColor(Color.WHITE);
				tb1.setTextSize(15);
				tb2.setTextColor(Color.parseColor("#B0E0E6"));
				tb2.setTextSize(20);
				
			}
			
		}

}
